//
//  MGJRouter.h
//  Express
//
//  Created by lhongl on 2025/9/28.
//  Copyright © 2025 QM. All rights reserved.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

extern NSString *const MGJRouterParameterURL;
extern NSString *const MGJRouterParameterCompletion;
extern NSString *const MGJRouterParameterUserInfo;


typedef void (^MGJRouterHandler)(NSDictionary *routerParameters);


typedef id _Nullable (^MGJRouterObjectHandler)(NSDictionary *routerParameters);

@interface MGJRouter : NSObject


+ (void)registerURLPattern:(NSString *)URLPattern toHandler:(MGJRouterHandler)handler;


+ (void)registerURLPattern:(NSString *)URLPattern toObjectHandler:(MGJRouterObjectHandler)handler;


+ (void)deregisterURLPattern:(NSString *)URLPattern;


+ (void)openURL:(NSString *)URL;


+ (void)openURL:(NSString *)URL completion:(void (^_Nullable)(id result))completion;


+ (void)openURL:(NSString *)URL withUserInfo:( NSDictionary * _Nullable )userInfo completion:(void (^_Nullable)(id result))completion;


+ (id)objectForURL:(NSString *)URL;


+ (id)objectForURL:(NSString *)URL withUserInfo:(NSDictionary * _Nullable)userInfo;


+ (BOOL)canOpenURL:(NSString *)URL;


+ (NSString *)generateURLWithPattern:(NSString *)pattern parameters:(NSArray *)parameters;

@end

NS_ASSUME_NONNULL_END
